package com.example.nfcproducttracing;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

public class PesticideFragment extends Fragment {	
	
	Pesticide pesticide;
    int px;
    
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    	setRetainInstance(true);
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.pesticide, container, false);
    }
    
    @Override
    public void onActivityCreated(Bundle savedInstanceState)
    {
		super.onActivityCreated(savedInstanceState);
    	
    }
	
    @Override
    public void onResume()
    {
        super.onResume();
        
        if (pesticide == null)
        {   
        	pesticide = ((PesticideActivity) getActivity()).readNDEFRecord(((PesticideActivity) getActivity()).getIntent());
        }
        
        Button pesticideHeader = (Button) getView().findViewById(R.id.PesticideHeader);
        TextView pesticideInstructions = (TextView) getView().findViewById(R.id.PesticideInstructions);
        
        pesticideHeader.setText(pesticide.name);
        pesticideInstructions.setText("Instructions :\n\n" + pesticide.instructions);
    }
}
